<template>
    <div>
        <template v-if="file.size">
            <span v-if="file.size<1024">{{Math.round(file.size)}} Byte</span>
            <span v-else-if="file.size/1024<1024">{{(file.size/1024).toFixed(1)}} KB</span>
            <span v-else-if="file.size/1024/1024<1024">{{(file.size/1024/1024).toFixed(1)}} MB</span>
            <span v-else>{{(file.size/1024/1024/1024).toFixed(1)}} GB</span>
        </template>
        <template v-else-if="file.isDir && file.length">
            <span v-if="file.length">{{file.length}}个文件</span>
        </template>
    </div>
</template>

<script>
    export default {
        name: "FileSizeText",
        props: {
            file: {
                type: Object,
                default: {}
            }
        },
    }
</script>

<style scoped>

</style>